/**
 * 
 */
package com.pmsco.pms.services.impl;

import java.util.List;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import com.pmsco.pms.core.dao.SubCategoryDao;
import com.pmsco.pms.core.domain.SubCategory;
import com.pmsco.pms.services.interfaces.SubCategoryService;

/**
 * @author Long Tran
 *
 */
public class SubCategoryServiceImpl implements SubCategoryService {
	private static final Logger logger = LoggerFactory.getLogger(SubCategoryServiceImpl.class);

	private static SubCategoryDao subCategoryDao;
	
	public SubCategory getSubCategoryByName(String name) {
		logger.info("Start getSubCategoryByName");
		logger.debug("Name: " + name);
		SubCategory subCategory = new SubCategory();
		subCategory.setName(name);
		logger.info("End getSubCategoryByName");
		return subCategoryDao.loadSubCategory(subCategory);
	}

	public SubCategory getSubCategoryById(Long id) {
		logger.info("Start getSubCategoryById");
		logger.debug("Id: " + id);
		logger.info("End getSubCategoryById");
		return subCategoryDao.getSubCategoryById(id);
	}
	
	public void deleteSubCategory(SubCategory category) {
		logger.info("Start deleteSubCategory");
		subCategoryDao.deleteSubCategory(category);
		logger.info("End deleteSubCategory");
	}

	public List<SubCategory> listSubCategory(SubCategory searchTemplate) {
		return subCategoryDao.listSubCategory(searchTemplate);
	}
	
	public List<SubCategory> listSubCategory(String searchField, String searchString, String searchOper, String sidx, String sord, Integer page, Integer rows) {
		return subCategoryDao.listSubCategory(searchField, searchString, searchOper, sidx, sord, page, rows);
	}
	
	public Integer countListSubCategory(String searchField, String searchString, String searchOper) {
		return subCategoryDao.countListSubCategory(searchField, searchString, searchOper);
	}
	
	public void saveOrUpdateSubCategory(SubCategory subCategory) {
		subCategoryDao.saveOrUpdateSubCategory(subCategory);
	}
	
	/**
	 * @param categoryDao the categoryDao to set
	 */
	public void setSubCategoryDao(SubCategoryDao subCategoryDao) {
		logger.info("Start setSubCategoryDao");
		logger.debug("SubCategory Dao: " + subCategoryDao);
		this.subCategoryDao = subCategoryDao;
		logger.info("End setSubCategoryDao");
	}

}
